package org.abettor.pushbox.util;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class FileUtil {
	/**
	 * 读取文件为二进制文件
	 * @param filename
	 * @return
	 * @throws IOException
	 */
	public static byte[] readFileByPath(String filename) throws IOException{
		File file = new File(filename);
		if(!file.exists()){
			return null;
		}
		InputStream in = new FileInputStream(file);
		ByteArrayOutputStream byteout = new ByteArrayOutputStream();
		int value = 0;
		while((value = in.read())!=-1){
			byteout.write(value);
		}
		in.close();
		return byteout.toByteArray();
	}
}
